import java.util.ArrayList;
import java.util.List;

/**
 * @Author DengJia
 * @Date 2021/8/9 23:01
 * @Description 使用break和return来达到同样的效果（打印到99退出）
 */

public class BreakAndReturn {
    public static void main(String[] args) {
        breakDemo();
        System.out.println();
        returnDemo();
    }

    static void breakDemo() {
        for (int i = 1; ; i++) {
            System.out.print(i + " ");
            if (i == 99) break;
        }
    }

    static void returnDemo() {
        int i = 1;
        while (true) {
            System.out.print(i + " ");
            if (i == 99) return;
            i++;
        }
    }

    static void testLabel() {
        http:
        for (int i = 0; i < 10; i++) {
            https:
            for (int j = 0; j < 10; j++) {
                if (i==5) continue http;
                if (j==7) continue https;
            }
        }

        List<String> list = new ArrayList<>();
        foreachLabel:
        for (String s : list) {
            System.out.println(s);
        }

        whileLabel:
        while (true) {
            System.out.println("死循环");
        }
    }

}
